//
//  NetThread.cpp
//  FreeNet
//
//  Created by cc on 12-7-5.
//  Copyright (c) 2012年 cc. All rights reserved.
//

#include "NetThread.h"

namespace FreeNet {
    
#if defined (__LINUX__)
#elif defined (__MACOSX__)
    void createThread(pthread_t& threadID, THREAD_WORKER tfunc, void* param)
    {
        int res = -1 ;
        pthread_attr_t attr ;

        res = pthread_attr_init(&attr) ;
        assert(!res) ;

        res = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) ;
        assert(!res) ;

        int errno = pthread_create(&threadID, &attr, tfunc, param) ;
        assert(0 == errno) ;

        res = pthread_attr_destroy(&attr) ;
        assert(!res) ;
    }

    void destroyThread(void* param)
    {
        pthread_exit(param) ;
    }

#endif
}

